home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / dialog / ftitle.c < prev    next >
C/C++ Source or Header  |  1996-08-01  |  2KB  |  81 lines

  1. #include "diadef.h"
  2. #include "dialog.h"
  3.  
  4. class FIELD_TITLE: public FIELD_STRING{
  5.     /*~PROTOBEG~ FIELD_TITLE */
  6. public:
  7.     FIELD_TITLE (const char *_prompt,
  8.          const char *_str);
  9.     void drawtxt (WINDOW *win);
  10.     void html_draw (int);
  11.     int html_validate (int);
  12.     /*~PROTOEND~ FIELD_TITLE */
  13. };
  14.  
  15. PUBLIC FIELD_TITLE::FIELD_TITLE(
  16.     const char *_prompt,
  17.     const char *_str)
  18.     : FIELD_STRING (_prompt,(char*)_str,strlen(_str))
  19. {
  20.     readonly = 1;
  21. }
  22.  
  23. PUBLIC void FIELD_TITLE::drawtxt(WINDOW *win)
  24. {
  25.     // Draw an horizontal line
  26.     wmove(win, box.y, box.x);
  27.     wattrset(win, inputbox_attr);
  28.     if (strcmp(buf,"-")==0){
  29.         // Special case, draw a small separator
  30.         for (int i=0; i<10; i++) waddch(win, ACS_HLINE);
  31.     }else{
  32.         for (int i = 0; i < box.width; i++) waddch(win, ACS_HLINE);
  33.         // Draw the text in the middle
  34.         int len = strlen(buf);
  35.         if (len > 0){
  36.             wmove(win, box.y, box.x + (box.width-len)/2);
  37.             waddstr(win, buf);
  38.         }
  39.     }
  40. }
  41.  
  42. /*
  43.     Draw the field with the prompt
  44. */
  45. PUBLIC void FIELD_TITLE::html_draw(int)
  46. {
  47.     if (strcmp(buf,"-")==0){
  48.         html_printf ("<tr><td>%s<td><hr>\n",prompt);
  49.     }else{
  50.         html_printf ("<tr><td>%s<td><strong>%s</strong>\n",prompt,buf);
  51.     }
  52. }
  53. PUBLIC int FIELD_TITLE::html_validate(int)
  54. {
  55.     return 0;
  56. }
  57.  
  58. /*
  59.     Add a new field/title.
  60.     A field/title act as a splitter between to logical section
  61.     of a dialog
  62.  
  63.     There are 3 cases:
  64.  
  65.     msg contain a string. It will appear centered with horizontal
  66.     rules on each side.
  67.  
  68.     msg is empty. A single horizontal rule will be drawn filling the line.
  69.  
  70.     msg is "-". A left justified horizontal rule will be drawn, not filling
  71.     the line.
  72. */
  73. PUBLIC void DIALOG::newf_title(const char *prompt, const char *msg)
  74. {
  75.     FIELD_TITLE *ti = new FIELD_TITLE(prompt,msg);
  76.     add (ti);
  77. }
  78.  
  79.  
  80.  
  81.